package org.zjx.analysis.analyze.window.impl;

import lombok.Getter;
import org.zjx.analysis.analyze.window.AbstractWindowAnalyzer;
import org.zjx.analysis.identify.IdentifyTessUtil;
import org.zjx.command.entity.ParagraphBean;
import org.zjx.command.entity.Pet;
import org.zjx.command.util.ImageUtil;
import org.zjx.window.window.IWindow;

import java.awt.*;
import java.awt.image.BufferedImage;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PetAnalysis extends AbstractWindowAnalyzer {
    @Getter
    private int petCount;
    @Getter
    private int maxPetCount;
    @Getter
    private int choosePetIndex;
    @Getter
    private Pet pet;

    public PetAnalysis(IWindow window) {
        super("宠物识别", "采集", window);
    }


    //参展按钮区域坐标
    public Rectangle getWarButtonRectangle() {
        return conversion(windowArea,imageMap.get("参战").getRectangle());
    }

    //获取宠物排序位置
    public Rectangle petIndex(int index){
        Rectangle box = areaMap.get("宠物列表").getRectangle();
        return conversion(windowArea,new Rectangle(box.x,box.y + index * 42,box.width,42));
    }

    private int analysisChoosePetIndex() {
        List<Color> chooseColors = Arrays.asList(new Color(93, 91, 228), new Color(167, 172, 114));
        for (int i = 0; i < Math.min(petCount,4); i++) {
            BufferedImage bufferedImage = ImageUtil.cutImage(screenshot,petIndex(i));
            if (ImageUtil.haveColor(bufferedImage,chooseColors)) {
                return i;
            }
        }
        return -1;
    }

    @Override
    protected void initResources() {
        areaMap.put("宠物列表", new ResolutionArea(ImageUtil.createRect(13,35,171,202)));
        areaMap.put("宠物名称", new ResolutionArea(ImageUtil.createRect(202,218,290,233)));
        areaMap.put("宠物数量", new ResolutionArea(ImageUtil.createRect(119,221,131,231)));
        areaMap.put("宠物最大数量", new ResolutionArea(ImageUtil.createRect(136,221,145,231)));
        areaMap.put("忠诚度", new ResolutionArea(ImageUtil.createRect(50,422,78,436)));
        areaMap.put("潜力", new ResolutionArea(ImageUtil.createRect(199,369,225,383)));
        areaMap.put("气血", new ResolutionArea(ImageUtil.createRect(47+ 5,242,149- 5,259)));
        areaMap.put("魔法", new ResolutionArea(ImageUtil.createRect(47 + 5,267 + 1,149 - 5,284 - 1)));

        imageMap.put("关闭按钮", new ResolutionImage(ImageUtil.createRect(353,6,362,15),
                ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAABCUlEQVR4Xl3Q0UrCYBQH8PM+hU7mwC23eZFWb+FNtQxx0UKL3qBuAukiixTcKNEbzQtBQQiKVGoKvodv8M/vOId1cW6+8+P/P3zU6M1Ra33DPLiEkiogbuSxHc9iS85CTlq4qwxgX1VBAg39BbzubIlLjCX1mNFzY8S72/seyNgrMlrhKeOd9HmIHtwPxNQjkKSdcO0mXrdUvE8kxDlmHhRVrWWdHeApAzGPL1/Q0g6fIoZiWo6hvl8MkzbPkPVTREW1Yhb+oKfXUZhc7/xA0XP8A/QfibpkxkG9vXpzOz70zAWoXH0P0JiRpFmcIJLcN593IojOrj3clPtQdx1EEoeM1mMGbbXmBL9SnAB2hhqkzQAAAABJRU5ErkJggg==")
        ));
        imageMap.put("参战", new ResolutionImage(ImageUtil.createRect(315,189,358,210),
                ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAACAAAAAQCAYAAAB3AH1ZAAADLElEQVR42sVUaUhUURSe/0Vl2w+pDCIiiyDIHNzIFktaKMuMMBRbLS3zh7aIWU6O2pg6OqPpWIlLmqKZmkuLODaaJmoWaeZSlhstaEUJhV9zj73rPHtZ/YgOfNxzv/udc747896TxVvY4X9Cpp5ni18hf/cxPIhKxkQaAal2rig7dlbEaRetgSE8EWrjoFKfM5J1spg5tpDCrcPBYNGQlEX7axv3ovOOAVrL9ZL6OnUq6U256y7exCUudab16+cv0C52EmlkUeY2MEXsgtVoL9NTQXNGAedu7j8FIdKcPDG+rvaHgWqVjpC0YivSnb2IY+cao/GhV30oPhIiqhMZKDwYhAljZISnmiUbJA0MD33E8OAH5O7y4/1qoq+gragCb1s78L6jW2wgYrYcDBfnr0LObn/UxqehTpOBamNRfVI2NWgvq0LWdh9CtutRdN6roVU1xx5CfU3MVdIK+xK/8yLvbPDzEj0qQuK4hoEbKA+8gL+NggNBvzQggEXmVm/K37Z1Ic8zUGxAOcMa41Hir6TCvqYWRFk4ojmzEI+ziokb7O41/hK+Y/qZcklz6ZsP0TmLu8FqJFrtoPySfKdoFjcQaW6PinMa3qDjtgFNaQV8zwrvq1Iw9Lqfc1URyYhfuonybLfjuGTtSjoWlYoE6tvb8BQ99U/wQl9P/PjLyhTTVoKhUplEgvrkHHRVPqT8Q88AygJVyNjmS/s3rZ1QmFkj1nIT6XPcAyhnwVahF4uK0ATKSwNU3HCRr4JrBMjGEwwR5g5IcfSAPkKHr1+GqfiloRHqJaPD2K0E7e8MRM515AbYvjH1BvK8To8ZCJ1kBVMU+Yif3vbyaiSscEOu+wnORS9w5vqYhRtHP0DGVeDIQIiW8v5Hz3idcGa4mMq1PxlQzrDD1bX7ED7bAdrlO6AP1/EGLTfuIWy6rUgvGEi0csP5qXKEmdnwIewvpIcwKI7WuoTR1zp3z0lpA6zJyLdvPz3RDVfyRbc2hWKK9FvwaeAdrRlbfElXFXmZn4XPspc2EGWxDnqlDoXeoUi23YPQySslh0qB3V6AKWeq0dl7QLPMRcTJ/nTAv8J3V1oLweYABqEAAAAASUVORK5CYII=")
        ));
        imageMap.put("休息", new ResolutionImage(ImageUtil.createRect(315,189,358,210),
                ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAACwAAAAWCAYAAAC7ZX7KAAAEIUlEQVR4Xs2XfUxVZRzHzz+mAePt4gWS7m24taUh5uTlctGlRVq6IF4mEY4Jm8KaTYkQs5UvEMOL4hUQeZFECAGlNSJCChhWYwPKBWwUq7Ul1dCJOoeFUj/v93d3Tueex3tH/XP7bZ+d8/zO8/J5nvucc8+RfIOeIDtG8vMLIH8vT/J/dDEtXbzIrcABLnCCm+wpBa2OpsCwCArw8aVdz8dRW14BjVisNF5R7VbgAJedG59jNzjCVYK9v6cnFSQkcsW+Hbl0ISaFThk2UIUx1q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5DOw4OlsfSYESq6EzjABU5wg6PyTRcUHkWBK9eSfpmRZ4L3TtyR7gQOcIET3OAI1wcp/CoFUbEuOQAAAABJRU5ErkJggg==")
        ));
        imageMap.put("推荐", new ResolutionImage(ImageUtil.createRect(242,365,310,386),
                ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAAEUAAAAWCAYAAACWl1FwAAAGbElEQVR4XuVYaVAUVxDeP4mJpJRDEaOCR5lUVEpM1AUBS/DEC2K0QMR4RYiJUVREVKIYgXDItSiwgggeGBBElAJBajFqERUDigcREzVoxCMWRsWztMPXm5namVmCVuXXpqu+2u6efv1ef9Pvzc6ozG16kx52ZGHRhSzfMyPLdztQ1w5vmTxQJ+pF3ahf4EJl4+BI3eyHUZfO5hQwZizlBYXQ6dgkOr9Za/JAnajX33001w8ewIcKDFmamVGI1zQO1M1bTntHzKAUWzfabOdi8sjuO5br/dLekXkAHypr277cIWAtdbinYtD/BWiCydY9CXyowA5aCIRobJ0VqIrRktZ+gmiXLAqlQ4vX05b+bpQ+ZJIi3hDly8Kp9Ot1Cv+FPQdp21Dj86UNHMf55f43QUVQJOV5+iv8/wYQs9buY+4WlVXrYYMtk9jT2SggRXODJXbdzkLSrY1jPW2QhyS+IjiaXjx5yhBEsNvyl6+IFMeXBYbzNfk6TiZup4v5pSJ+DEtSxAh4fK+Zbpw4QwXeSxRIGTBeES8A5IAPFU5h7Km490dIkOYwhQp8l/ECT2qyKV39GeX7BLJdnZpDleuTWL/XcJUq1yWSLjSBtJ94UobTDKpYHct4/qiFFwj9SJhG9EPO5RwQbeTOmeLPfrk0FFdS4ZyVrLfcuUcPm+7Sk+YHbKcPn6ZYN4A525LjUVpFvABsIfDBpOCwkQfU7yuTJLtb/5vENiYHA0IpwdaVdk9cQDmTF1LJ4g1UvGgd/RSfydfhA46Gp9APXotY3+Uxn+J6OFNSP3cqXxlFf5yq41iQ9fux06wjB8RwfZAsNz/FugGQAtLl/vagICXa2tEoIAWzg6ixqob1x382S65VhiVL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GeXCR0EIbOMew8FIRtIgBdAz86A1vUMJdWPVPUEYsYwd499RuK7TlaEo8uwT/aCIdp/F1FZWHRlV+Z4QRbhsGmDpABoCEynRbQ9F6DCXyo+Ktbp07swJsintlCsKkDjYAts9MlgPz6DWYewIeKv0ta25JVx45MDFoIrCHQ1IE6US/qRv3gQfxGazNYTd0GDiXrHnbMFr4p4BQ2daBO1Iu6UT94AB9/A9+sfUeOgqZSAAAAAElFTkSuQmCC")
        ));
        imageMap.put("确认加点", new ResolutionImage(ImageUtil.createRect(297,392,358,413),
                ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAAD4AAAAWCAYAAACYPi8fAAAGEklEQVR4Xt1Ya1BVVRS+f8rURrmCSA0qqVkpDmgJKOigoukAYo7lexAfYGbqGAg+swTkGVzBK8hDxMC8gqASLxWGNHwBiqCWNo4pSlqOqIWWyopvndnHe8+5vmb6010z3+xvrb32Pvvbe51zz7kaO2c3Yji5km2vPmSj1ZJ1p47UvcMrFgFogSZog0ahV2Nl50BWPXpTt86dKchrLBmCw6gmVkeNyakWAWiBpsDRY1gjtEKzBrtg09WKwiZN5sSKgOW0e/jHpO81ipJ7e1gEtvcZy5oWDnJjrdCs0Wpt+KSxM1tc/FSDLAk4TB9be4JmDXYApQDRm3q5m8Xmfp50seiQKv6iOByeTGlDfFRxgZSB46h08Zeq+MvgYHAkGfwCVXFjQPzq3kP41DXWr73K5Z1o7077AkJJaTfqz1PZsnDmd642M5rrGimp3ygeI5AzPoBzihetM4kDsEOhMaq4gJhfGT+euI3O5ZXIqFqvU+UItN66TU3HTlP+1CUq6Ad8KOdhA6BZgycf6j/+zeGU+r4fVcel08PW+7wQ8O8/W8+85XIT1aUb6EzOXvbTXCbzGGPUpu3ivrLlkSZx2MGVsar8XN9A7lPahaJKKvAPYf7XzVt0r/l3un/7LvvmrgtA+NPsSFSqnIdyh2YWjptfudBjuizm2EUYNqFqQzJdPXqKfXBsinIBGe6fUFJ/L9V85oTr+o6m8pAounbijJzz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9fpNvTXBUG6xocQSXOr5JoFmDb1S8uOM3TikASHacRKmu02Ufi8IFDdNCzIoGYu3H8AKVcQFUT3gXN25F3qb3JvJGRdmOlPOwaJS0AE4fcZwwKtJ4TuM1Ihc5ws+Z+DlFO0hvpxHOk/m7XNPd/i3+VEMQO6Jc5P8dKG8AB5s5bB5N6elE0Mz/wFh36sQBfL3g904kWwJwoCjvHR5BNKuvE2uV/oFxdiPbd53JpksXFo9SwM4g0RIALdAEbdAIrU/+c7OT/ofqprXhHcH3Kp58lgBogSZoM9b6LwC7H2oF7KAiAAAAAElFTkSuQmCC")
        ));
    }

    @Override
    public Rectangle closeArea() {
        return ImageUtil.createRect(353,6,362,15);
    }

    @Override
    public Rectangle getOriginBounds() {
        return ImageUtil.createRect(5, 63, 375, 537);
    }

    @Override
    public Rectangle getRefImageArea() {
        return ImageUtil.createRect(151, 3, 219, 15);
    }

    @Override
    public BufferedImage getRefImage() {
        return  ImageUtil.createImage("iVBORw0KGgoAAAANSUhEUgAAAEUAAAANCAYAAAD/hqMoAAAFZklEQVR4XqVWC1NTRxTOz9LpTKvt6NQpzEABH9EWFVBRaNEpVUSxOCIhU0UBkZBISgAJPhpEQBSwIBiTBjQgUBEEISbIG3kpoJ7uOTe73NzQkJl+M9/c3bNn95zz3d27V7Uh5BIQw5AF/4tfRBRCUnqNrz1SQa/99IUGiE+9s+rjfV6v6oDYkxZff/b8MkoPscctcDClcpWnFGS2A4ybdxp8crhcZIWQfSa/fCMPXYeiG+1AtXMdGFVjE3MQLKxPh0Wy5upOePJsGB7ZB2HHETMF0eiaya+7b5R4q67LXxQvsXjE/hO3he2S8THZks7V+PlPTi+KPIKBfC4iI7+JctwYLvW37jFCtkGKtyqUV5SkdAtoCx562QIdPSPkiG057c9cItjuhHJqtz1309PaPkyLLq98goXFZRJrZFwS+yu13ifBjVEF8PkzDa2LkDiTT2G9gxOgr3AE5P2WPvLdpBAFa/hGXUQ7BnFCcx9qHvZSGzVAxqfeJGFU0rFZ5aB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+SRMm8WA1pmZY1yYXTmZrEghjEXGmHkgorhO3OAXVcAftxk67mn1PZDXJAKmRyap7aPEGeZFqWRVYcT1Tqxx2Tbp+t21EUDRPjNvX5d4vfJHIssf8TRFau9Fshrb8aT5tTSwWH7rxE+SKNZS00xvvIzaFMlMjoK9KqQSAmschHUc5vIy4In/0J14Q94sc88LydIfuFvDqfJIMB90fxEXHHjMIeFXOF7QqpCIylxKGjxSIPhPZyLSSnSf9XgdDKdv2/c++2zl5eCeoAAAAASUVORK5CYII=");
    }

    @Override
    public void analyze(BufferedImage image) {
        Map<String, Rectangle> areas = new HashMap<>();

        // 定义所有需要识别的区域
        areas.put("宠物数量", conversion(windowArea,areaMap.get("宠物数量").getRectangle()));
        areas.put("宠物最大数量", conversion(windowArea,areaMap.get("宠物最大数量").getRectangle()));
        areas.put("忠诚度", conversion(windowArea,areaMap.get("忠诚度").getRectangle()));
        areas.put("气血", conversion(windowArea,areaMap.get("气血").getRectangle()));
        areas.put("魔法", conversion(windowArea,areaMap.get("魔法").getRectangle()));
        areas.put("潜力", conversion(windowArea,areaMap.get("潜力").getRectangle()));

        Map<String, String> batchIdentify = IdentifyTessUtil.batchIdentify(screenshot, areas);

        petCount = Integer.parseInt(batchIdentify.get("宠物数量"));
        maxPetCount = Integer.parseInt(batchIdentify.get("宠物最大数量"));

        //获取选中的宠物是哪个
        choosePetIndex = analysisChoosePetIndex();


        pet = new Pet();
        List<ParagraphBean.Word> words = identifyFont(areaMap.get("宠物名称").getRectangle());
        pet.setName(words.get(0).getName());

        pet.setWar(haveButton(imageMap.get("休息")));
        String loyal = batchIdentify.get("忠诚度");
        pet.setLoyal(Integer.parseInt(loyal));


        String health = batchIdentify.get("气血");
        String mana = batchIdentify.get("魔法");

        String[] heal = health.split("/");
        pet.setHp(Integer.parseInt(heal[0]));
        pet.setMaxHp(Integer.parseInt(heal[1]));
        String[] ma = mana.split("/");
        pet.setMp(Integer.parseInt(ma[0]));
        pet.setMaxMp(Integer.parseInt(ma.length > 1?ma[1]:ma[0]));

        String potential = batchIdentify.get("潜力");
        pet.setPotential(Integer.parseInt(potential));
    }
}
